<#assign script_controller = 'group/group_member' />
<@block_title "${groupinfo.title}小组" />

<#assign groupNav = 'member' />

<#include '/group/layout.ftl'/>

<#macro blockGroupBody>
  <@web_macro.flash_messages/>

  <div class="row">
    <div class="col-md-12">
      <div class="panel panel-default panel-lg">
        <div class="panel-heading"><h1>成员列表</h1></div>
        <div class="panel-body">

        <h4>组长</h4>
        <div class="clearfix">
          <div class="grouplist" >  
            <a href="${ctx}/user/${owner_info.id}" title="${owner_info.username}"  >
            <img src="${default_path('avatar',owner_info.largeAvatar, 'large')}" alt="${owner_info.username}" >
            </a> 
            <p class="mvs"><a href="${ctx}/user/${owner_info.id}" title="${owner_info.username}">${owner_info.username}</a>
            </p>
          </div>
        </div>


        <h4>副组长</h4>
        <div class="clearfix">
        <form action="{{path('group_remove_admin',{id:groupinfo.id})}}" method="post" id="admin-form"> 
          <#if groupAdmin??>
          <#if is_groupmember==2 || is_granted('ROLE_ADMIN')  >
          <button id="remove-admin-btn" type="button" class="btn btn-default btn-sm pull-right">撤消副组长</button> 
          </#if>
          <#list groupAdmin! as member>
              <div class="grouplist" style="width: 96px;" >
              {{ web_macro.user_avatar(usersLikeAdmin[member.userId] , 'clearfix  media-object media-object-small') }}
              <p class="mvs">{{ web_macro.user_link(usersLikeAdmin[member.userId] , 'link-muted') }}</p>

              {% if is_groupmember==2 or is_granted('ROLE_ADMIN') %}

                <input type="checkbox" value="{{member.userId}}" name="adminId[]"class="checkboxs"> 

              {% endif %}
              <br>
              </div>

          </#list>
          <#else>
            <p><sapn class="text-muted">还没有副组长！</span></p>
          </#if>
        </form>
        </div>

        <div class="btn-group pull-right">
          <#if groupmember_info??>

            <#if is_groupmember==2 || is_granted('ROLE_ADMIN') || is_groupmember==3 >
              <button  id="delete-btn" type="button" class="btn btn-default btn-sm ">踢出成员</button> 
            </#if>

            <#if is_groupmember==2 || is_granted('ROLE_ADMIN') >
              <button  id="set-admin-btn" type="button" class="btn btn-default btn-sm ">设置副组长</button>
              <input id="set-admin-url" type="hidden" value="{{path('group_set_admin',{id:groupinfo.id})}}"> 
            </#if>

          </#if>
        </div>
        <form action="{{path('group_member_delete',{id:groupinfo.id})}}" method="post" id="member-form" class="clearfix"> 

             <h4>组员</h4>

          <#if groupmember_info??>
             
                  <#list groupmember_info! as member>
                    <div class="grouplist" style="width: 96px;" >
                      {{ web_macro.user_avatar(members[member.userId] , 'clearfix  media-object media-object-small') }}
                      <p class="mvs">{{ web_macro.user_link(members[member.userId] , 'link-muted') }}</p>

                      <#if is_groupmember==2 || is_granted('ROLE_ADMIN') || is_groupmember==3>
                        <input type="checkbox" value="{{member.userId}}" name="memberId[]"class="checkboxs">
                      </#if><br>
                    </div>

                  </#list>
                  
                  <#if is_groupmember==2 || is_granted('ROLE_ADMIN') || is_groupmember==3>
                    <input type="hidden" name="_csrf_token" value="${csrf_token('site')}">
                  </#if>
            
          <#else>
                   
                      <p><sapn class="text-muted">还没有小组成员！</span></p>



          </#if>
        </form>

        <div class="pull-right"><@web_macro.paginator paginator!/></div>

        </div>
      </div>
    </div>
  </div>

</#macro>